
/* Copyright (c) 2006-2016, Stefan Eilemann <eile@equalizergraphics.com>
 *                          Cedric Stalder <cedric.stalder@gmail.com>
 *                          Daniel Nachbaur <danielnachbaur@gmail.com>
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License version 2.1 as published
 * by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#include "eventHandler.h"

namespace eq
{
void EventHandler::_computePointerDelta(const EventType type,
                                        PointerEvent& event)
{
    switch (type)
    {
    case EVENT_WINDOW_POINTER_BUTTON_PRESS:
    case EVENT_WINDOW_POINTER_BUTTON_RELEASE:
        if (_lastEventType == EVENT_WINDOW_POINTER_MOTION)
        {
            event.dx = _lastPointerEvent.dx;
            event.dy = _lastPointerEvent.dy;
            break;
        }
    // fall through

    default:
        event.dx = event.x - _lastPointerEvent.x;
        event.dy = event.y - _lastPointerEvent.y;
    }
    _lastEventType = type;
    _lastPointerEvent = event;
}
}
